<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class ShopGoodsCarts extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
      Schema::create('shop_goods_carts', function (Blueprint $table) {
        $table->increments('id');
        $table->unsignedInteger('user_id');
        $table->unsignedInteger('goods_id');
        $table->unsignedInteger('attr_id');
        $table->string('goods_name', 100);
        $table->string('goods_pic', 255);
        $table->decimal('price', 10, 2);
        $table->tinyInteger('buy_num');
        $table->string('color', 20);
        $table->tinyInteger('size');
        $table->integer('addtime');

        $table->foreign('user_id')
              ->references('id')->on('shop_home_users')
              ->onDelete('cascade');

        $table->foreign('goods_id')
              ->references('id')->on('shop_goods')
              ->onDelete('cascade');

        $table->foreign('attr_id')
              ->references('id')->on('shop_goods_attrs')
              ->onDelete('cascade');
      });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
      Schema::dropIfExists('shop_goods_carts');

    }
}
